package IO.File;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class FileTest {
    public static void main(String[] args) {
        File file = new File("D:\\IOFile\\test\\a\\word.docx"); //is Directory  目录
        System.out.println(file.exists());
        file.mkdir();
        System.out.println(file.exists());
        file.mkdirs();
        System.out.println(file.exists());
        System.out.println("isDirectory : "+file.isDirectory());
        System.out.println(file.isFile());
        String path = file.getPath();
        System.out.println(path);

        //获取文件夹下所有文件对象 listFiles
        File file1 = new File("D:");
        File[] files =file1.listFiles();
        for(File f: files){
            System.out.println(f);
        }

        File file2 = new File("D:/IOFile/test/word.txt");
        if(!file2.exists()){
            try {
                file2.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
